Macromedia Central Development Quick Start Guide
Mike Chambers
Developer Relations Product Manager, Macromedia
This Quick Start Guide provides a no-frills, step-by-step guide to getting started with your first Macromedia Central application. Here's what each step entails:
- Set up your development environment. This includes downloading and installing Macromedia Central; downloading the Central SDK; installing the Central components; installing the Central Help Panel documentation, code hinting and authoring templates; and installing the Central Debug panel.
- Develop your Central application. This involves creating a new FLA, setting the frames per second, setting up the publish settings, adding ActionScript code to your application, adding a graphic to the Stage, and finally publishing the application.
- Install your application. This requires getting a product ID, creating the product.xml file, setting up the installation folder, copying the installation folder to a web server, install the application into Central, and finally checking the installation in Central.
- Test, develop, and debug the application. This means locating the application installation path, setting Flash to publish to the installation folder, testing your application, and debugging your application within Central.
This article gives you the basic skills to begin developing complex applications for Macromedia Central.
Additional Resources
- Macromedia Central Support Center
- Macromedia Central Resources
- Macromedia Central Development Central
- Macromedia Central Product Page
Setting Up the Development Environment
Here are the steps to set up the development environment.
Step 1. Download and Install Macromedia Central
This is as simple as going to the Macromedia Central installation page and clicking the installation badge.
Step 2. Download the Central Software Development Kit
The Central Software Development Kit (SDK) contains components, tools, utilities, documentation, and other resources necessary for developing Central applications. You can download the SDK from the Central SDK site.
Step 3. Install the Central Components
The SDK includes a set of components for creating applications in Central. You can find these in the components folder of the SDK and install them using the Macromedia Extension Manager.
Once they're installed, you can locate the components in the Components panel within Flash (see Figure 1), as follows:
- Flash MX 2004: Window > Development Panels > Components
- Flash MX: Window > Components
Figure 1. Central Components in the Flash MX 2004 Components panel
Step 4. Install the Central Help Panel Documentation, Code Hinting, and Authoring Templates
The Central SDK includes an MXP file that installs Reference/Help Panel documentation and code hinting for the complete Central and Central Component API. It also installs an authoring template for Central, which makes it easy to get started with a new application.
After you install the contents of the MXP, you can access the Help documents from the following locations:
- Flash MX 2004: Help > Help > Central
- Flash MX: Window > Reference Panel > Central
Step 5. Install the Central Debug Panel
The Debug panel in Central is included in the SDK. This panel runs within
Flash (see Figure 2) and displays trace() actions from applications
running within Central. It is analogous to the Output panel but provides
richer formatting and insight into the data being traced.
Figure 2. Central Debug panel running within Macromedia Flash
You can find the Debug panel in the Utilities\DebugPanel folder in the SDK. Once you install the panel with the Extension Manager, you can open it within Flash using the following:
- Flash MX 2004: Window > Other Panels > Central Debug Panel
- Flash MX: Window > Central Debug Panel
Developing Your First Application
Here are the steps to develop your first Central application.
Step 1. Create a New FLA
You can either create one from scratch or use the Central authoring templates that you installed in Step 4 on the previous page.
- Flash MX 2004: File > New > Templates > Macromedia Central > Central Application
- Flash MX: File > New From Template > Macromedia Central > Central Application
Step 2. Set the Frames Per Second
Set the frames per second for your application to 21 fps. This is the same rate at which Central runs.
Select the stage and choose Window > Properties > Frame Rate. If you used the authoring templates, you do not need to do this step.
Step 3. Set Up the Publish Settings
If you used the Flash MX 2004 authoring template, you can skip this step. Otherwise, make the following settings for whichever version of Flash you use:
-
Flash MX: File > Publish Settings > Flash
Version: Flash Player 6
Omit Trace Actions: Unchecked
Debugging Permitted: Unchecked
Compress Movie: Checked -
Flash MX 2004: File > Publish Settings > Flash
Version: Flash Player 6
ActionScript Version: ActionScript 1.0 (2.0 also works)
Omit Trace Actions: Unchecked
Debugging Permitted: Unchecked
Compress Movie: Checked
Optimize for Flash Player 6r65: Checked
Step 4. Add ActionScript to Your Application
You are now ready to add the bare code that's necessary for your application to run within Central. If you used the Flash MX 2004 authoring template, the stub ActionScript code is already inserted in your file.
Create a new layer on the Timeline and name it Actions. With the first frame selected, open the ActionScript editor:
- Flash MX 2004: Window > Development Panels > Actions
- Flash MX: Window > Actions
Add the following ActionScript code:
onActivate = function(shell, appID, shellID, baseTabIndex, initialData)
{
//initialization code goes here
shell.setStatus("Loaded");
}
onDeactivate = function()
{
//clean up code goes here
}
Central.initApplication(this, this);
The onActivate function is called when your application
is loaded into Central; it should contain any initialization code for
your application. The onDeactivate function is called when
your application is about to be closed; it should contain any cleanup
code, such as closing connections with the server, clearing intervals,
and _global variables.
Finally, Central.initApplication() tells Central that the
application is ready to be run. After this method is called, Central
calls your onActivate function.
Note that the shell.setStatus method in the onActivate function
sets the text within the Central status bar.
Step 5. Add a Graphic to the Stage
Create a new layer and add a graphic or shape to the Stage. This is temporary; it's only needed to provide a visual indication that your application has loaded into Central.
Step 6. Publish the Application
You are now ready to create the SWF file for the application. To do this, publish the file by selecting File > Publish.
If you get any ActionScript errors, correct them. Once the file has been published, there will be a SWF file in the same folder as the FLA. This is the application that you will next install into Central.
Installing Your Application into Central
Here are the steps to installing your application into Central.
Step 1. Get a Product ID
In order to install your application into Central, you must first get a product ID. Every application installed into Central needs a valid product ID. You can get one from the Macromedia Central Product ID site:
www.macromedia.com/go/central_productid
The SDK also includes a single product ID that you can use for local development purposes.
Step 2. Create the product.xml file
You need to create the product.xml file that Central uses to install and configure the application.
For this application, you can create a simple product.xml file as follows:
- Create a new text file named product.xml.
- Open it with a text editor.
- Add the following XML code to it, replacing the appropriate fields with information from your own application:
<?xml version="1.0"?>
<product name="Sample"
created="4/15/2003"
version="1"
lifetime=""
price="Free"
requireVersion="1"
category="Other"
vendor=""
vendorID=""
productID="CND100-062234-167221-651442">
<author name="Author Name" info="http://www.authorwebsite.com/"/>
<description>Sample application for Macromedia Central</description>
<application name="Sample"
src="sample.swf"
width="550" height="400"
lang="en"
background="#FFFFFF"
version="1"
hasPreferences="false">
</application>
</product>
Step 3. Set Up the Installation Folder
Create a new folder to contain all of the files necessary to install your application. Copy the following files into that folder:
- The application SWF file
- The product.xml file
- The installation badge (a Flash application)
You can find the installation badge in the SDK in the Utilities\InstallationBadge folder. This is what the installation badge does when you put it on your website:
- Loads the product.xml file
- Displays information about your application
- When clicked, starts the installation process into Central
Step 4. Copy the Installation Folder to a Web Server
All Central applications must be installed using a web server. During development, you can do this installation using a local web server. Copy the installation folder and its contents to a local or remote web server.
Step 5. Install the Application into Central
Using a web browser, browse to the installation folder on the web server and load the installation badge. Once it has loaded, click it to install your application into Central.
If any errors occur, confirm that product.xml contains no errors and that all the files are included in the installation folder.
Note that you can also type the URL to the product.xml file directly into Central by choosing File > Install Application from URL (see Figure 3).
Figure 3. Installing an application into Central using the URL to product.xml
Step 6. Check the Installation in Central
Open Central, if it's not already open, and select your application from the toolbar at the top. This opens your application. You should see the graphic you inserted earlier (in Step 5 on the previous page) and also see the text "Loaded" appear on the status bar (see Figure 4).
Figure 4. Sample application loaded into Central
If you do not see either of these, recheck your ActionScript code and product.xml file, and reinstall the application.
Testing, Developing, and Debugging the Application
Once you have correctly installed your application into Central, you can set up Flash to publish it directly into Central. This allows you to test and debug your application easily within the Central environment.
This is important because you cannot test your application directly within the Flash authoring environment; it doesn't have integrated support for the Central APIs.
Step 1. Locate the Application Installation Path
The Central installation path for your application is similar to one of the following:
- Windows XP/2000: C:\Documents and Settings\USERNAME\Application Data\Macromedia\Central\#Central\RANDOMSTRING\DOMAINNAME\APPPATH
- Windows 98: C:\Windows\Profiles\rhash\Application
Data\Macromedia\Central\#Central\RANDOMSTRING\DOMAINNAME\APPPATH - Mac OS: Hard Drive/Users/USERNAME/Library/Application Support/Macromedia/Central/#Central/RANDOMSTRING/DOMAINNAME/APPPATH/
Step 2. Set Flash to Publish to the Installation Folder
Once you locate the Central installation path for your application, set Flash to publish directly into that folder and thus into Central:
In Flash MX 2004, select File > Publish Setting > Formats. Click the Folder icon and navigate to the Central installation path for your application. Make sure you save it as the same name as the SWF in that directory.
In Flash MX, select File > Publish Settings > Formats. Uncheck the Use Default Names option and enter the path to the Central installation folder, as well as the name that the file should be published as.
Step 3. Test Your Application
When you publish your application, it will overwrite the SWF installed
into Central. To test this, change the onActivate function
to print a different message on the status bar:
onActivate = function(shell, appID, shellID, baseTabIndex, initialData)
{
//initialization code goes here
shell.setStatus("Loaded Again!");
}
Publish your file (select File > Publish) and switch to Central. In order to see the new file, you must reload the application within Central. You can do this by switching to another application and then back to your application.
Notice that the new version is now running, as evident by text "Loaded Again!" appearing now on the status bar.
Step 4. Debug Your Application Within Central
Now that you can easily publish your application directly into Central, you need an easy way to get debug and trace information from the application as it runs within Central.
When you test non-Central applications within Flash, you get this information
using the trace() function and the Output panel. The process
is very similar to testing applications within Central because it uses
the trace() function and the Central Debug panel.
To test this, open the Debug panel within Flash:
- Flash MX 2004: Window > Other Panels > Central Debug Panel
- Flash MX: Window > Central Debug Panel
Next, add some trace statements to your application like so:
onActivate = function(shell, appID, shellID, baseTabIndex, initialData)
{
//initialization code goes here
shell.setStatus("Loaded Again!");
trace("onActivate Called");
}
Publish your application and reload it in Central. Switch back to Flash and you should see "onActivate Called" within the Debug panel.
One of the cool things about the Debug panel is that it provides rich output for complex data types. For example, replace your onActivate method with the code before and then test the application within Central:
onActivate = function(shell, appID, shellID, baseTabIndex, initialData)
{
var homer = new Object();
homer.firstName = "Homer"
homer.lastName = "Simpson"
var children_arr = new Array();
children_arr.push("Bart");
children_arr.push("Maggie");
children_arr.push("Lisa");
homer. children = children_arr;
trace(homer);
}
If you were to trace this within Flash, the Output panel would show this:
[Object object]
However, tracing this within the Debug panel in Central shows this:
Object : object
children : Array
[0] : Bart
[1] : Maggie
lastName : Simpson
firstName : Homer
As you can see, this provides much richer output and gives you insight into all of the data, rather than just the first level.
You now have the basic skills necessary to begin developing complex applications for Macromedia Central. Your next steps involve creating your application and adding pods and agents—topics for another day.